FThread Class Reference
[Thread Handling]

FThread wraps threads for each platform. More...

#include <fthread.h>

Public Member Functions

 FThread (const char8 *name="FThread")
 Thread constructor.
virtual ~FThread ()
 Destructor.
void run ()
 Starts the thread.
void terminate ()
 Terminates the thread.
bool isRunning ()
 Checks if thread is (still) running.
bool waitDead (int32 timeOut)
 Waits for thread dead.
virtual bool setPriority (int32 priority)
 Sets thread priority.
int32 getPriority ()
 Gets the current priority of this thread.
virtual void cleanup ()
 Override this method for any cleanup code.
virtual uint32 entry ()
 Override this method for the thread loop.
const StringgetName () const
 Gets the name of this thread.
void * getThreadReference () const
 Gets the reference of this thread.
bool setCpuAffinity (int32 cpu)
 Sets cpu affinity.
bool isInThreadContext () const
 Check if current execution is in the thread context.

Static Public Member Functions

static void setSpy (IThreadSpy *spy)
 Sets a thread spy which gets informed about new or removed threads.

Protected Attributes

int32 priority
 Priority of thread.
int32 cpu
 Cpu used by this thread.
bool running
 Running state.

Static Protected Attributes

static IThreadSpygSpy = 0
 Global thread spy.

Detailed Description

FThread wraps threads for each platform.

termination is best with waitDead and flags in the run loop....


Constructor & Destructor Documentation

FThread ( const char8 *  name = "FThread"  ) 

Thread constructor.

Parameters:
name the name of the thread (can be seen in debugger)
~FThread (  )  [virtual]

Destructor.


Member Function Documentation

void run (  ) 

Starts the thread.

void terminate (  ) 

Terminates the thread.

bool isRunning (  )  [inline]

Checks if thread is (still) running.

Returns:
true if running
bool waitDead ( int32  timeOut  ) 

Waits for thread dead.

This is the best to terminate this thread.

Parameters:
timeOut timeout in ms
Returns:
true if not timed out
bool setPriority ( int32  prio  )  [virtual]

Sets thread priority.

To boost priority a little bit permit a temporary raised task priority .

Permit temporary raise of task priority.

Parameters:
priority thread priority, see FThreadPriority
Returns:
true if successful

.... taskPriority defaults to static taskPriority if not set

int32 getPriority (  )  [inline]

Gets the current priority of this thread.

Returns:
priority, see FThreadPriority
void cleanup (  )  [virtual]

Override this method for any cleanup code.

uint32 entry (  )  [virtual]

Override this method for the thread loop.

Returns:
thread return value.
const String& getName (  )  const [inline]

Gets the name of this thread.

Returns:
thread name
void * getThreadReference (  )  const

Gets the reference of this thread.

Returns:
thread reference
bool setCpuAffinity ( int32  cpu  ) 

Sets cpu affinity.

Binds thread to a specific cpu.

Parameters:
cpu cpu id
Returns:
true if successful
bool isInThreadContext (  )  const

Check if current execution is in the thread context.

Returns:
true if successful
void setSpy ( IThreadSpy spy  )  [static]

Sets a thread spy which gets informed about new or removed threads.

There is only one spy allowed and it works without reference couting.

Parameters:
spy a thread spy

Field Documentation

int32 priority [protected]

Priority of thread.

int32 cpu [protected]

Cpu used by this thread.

bool running [protected]

Running state.

IThreadSpy * gSpy = 0 [static, protected]

Global thread spy.

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Empty

Copyright ©2013 Steinberg Media Technologies GmbH. All Rights Reserved.